﻿using Domain.Entities.Tenants;
using Domain.ValueObjects;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Entities.Identity;

/// <summary>
/// 菜单管理
/// </summary>
[Description("菜单管理")]
public class Menu : BaseAuditableSoftDeleteEntity, IAuditTrial, ITenant
{
    public Menu()
    {
        RoleMenus = new HashSet<RoleMenu>();
    }

    /// <summary>
    /// 父级节点
    /// </summary>
    [Description("父级节点")]
    public virtual long? ParentId { get; set; }
    [ForeignKey("ParentId")]
    public virtual Menu? Parent { get; set; }

    /// <summary>
    /// 路由名称
    /// </summary>
    [Description("路由名称")]
    public virtual string? Name { get; set; }

    /// <summary>
    /// 路由路径
    /// </summary>
    [Description("路由路径")]
    public virtual string? Path { get; set; }

    /// <summary>
    /// 路由重定向
    /// </summary>
    [Description("路由重定向")]
    public virtual string? Redirect { get; set; }

    /// <summary>
    /// 菜单高亮
    /// </summary>
    [Description("菜单高亮")]
    public virtual string? Active { get; set; }

    /// <summary>
    /// 组件路径
    /// </summary>
    [Description("组件路径")]
    public virtual string? Component { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    [Description("权限标识")]
    public virtual string? Code { get; set; }

    /// <summary>
    /// 链接地址
    /// </summary>
    [Description("链接地址")]
    public virtual string? Url { get; set; }

    /// <summary>
    /// 接口请求方式
    /// </summary>
    [Description("接口请求方式")]
    public virtual string? HttpMethods { get; set; }

    /// <summary>
    /// 元信息
    /// </summary>
    [Description("元信息")]
    public virtual Meta? Meta { get; set; }

    public ICollection<RoleMenu> RoleMenus { get; set; }

    [NotMapped]
    public virtual List<Menu> Children { get; set; } = new List<Menu>();
    public virtual Tenant? Tenant { get; set; }
    public virtual string? TenantId { get; set; } = null;
}
